package com.ld.wms.business.log.controller;


import com.ld.wms.business.log.service.CameraMonitorInfoService;
import com.ld.wms.business.log.vo.resp.CameraMonitorInfoRespVo;
import com.ld.wms.business.log.vo.resp.InventoryOperateLogRespVo;
import com.ld.wms.common.ResultResponse;
import com.ld.wms.common.vo.GeneratePageListVo;
import com.ld.wms.sysenum.ResultResponseEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wangfeng
 * @since 2025-06-05
 */
@Slf4j
@RestController
@Tag(name = "监控摄像头相关接口")
public class CameraMonitorInfoController {

    @Autowired
    private CameraMonitorInfoService cameraMonitorInfoService;

    @GetMapping("/api/wms/cameraMonitorInfo/getPageList")
    @Operation(summary = "监控列表")
    public ResultResponse<GeneratePageListVo<CameraMonitorInfoRespVo>> getPageList(
            @Parameter(description = "开始时间") @RequestParam String startTime,
            @Parameter(description = "结束时间") @RequestParam String entTime,
            @Parameter(description = "当前页数") @RequestParam(defaultValue = "1") Integer current,
            @Parameter(description = "每页展示条数") @RequestParam(defaultValue = "10") Integer size
    ) {
        log.info("req param startTime{}, entTime{}, current{}, size{}", startTime, entTime, current, size);
        GeneratePageListVo<CameraMonitorInfoRespVo> pageList = cameraMonitorInfoService.getPageList(current, size);
        return ResultResponse.success(pageList);
    }

    @GetMapping("/api/wms/cameraMonitorInfo/getVideo")
    @Operation(summary = "监控文件查看")
    public ResultResponse<ResultResponseEnum> getVideo(
            @RequestParam Long id,
            HttpServletResponse response) {
        cameraMonitorInfoService.getVideo(id, response);
        return ResultResponse.success(ResultResponseEnum.SUCCESS);
    }

}

